//
//  UIView+QHExtension.m
//  FuturesNews
//
//  Created by 张伟 on 2021/3/26.
//

#import "UIView+Extension.h"

@implementation UIView (Extension)

+ (instancetype)viewFromNib{
    NSString *nibName = NSStringFromClass([self class]);
    NSBundle *bundle = [NSBundle bundleForClass:[self class]];
    NSArray *nibContents = [bundle loadNibNamed:nibName owner:nil options:nil];
    
    for (id object in nibContents) {
        if ([object isKindOfClass:[self class]]) {
            return object;
        }
    }
    
    // 如果没有找到匹配的视图，返回nil并打印错误日志
    NSLog(@"Error: Could not load view from nib named %@", nibName);
    return nil;
}

@end
